#pragma once
#include "wOHandle.hpp"
#include "ProObjects.h"
#include <memory>
#include "wCollection.hpp"



namespace witotk{

	class wProSelection;
	
	typedef	std::tr1::shared_ptr<wProSelection> wProSelection_ptr;

	typedef	wCollectionshared_ptr<wCollection<wProSelection>> wProSelectionCollection_ptr;

	typedef	wCollection<wProSelection> wProSelectionCollection;

	class wProSelection:public wOHandle<ProSelection>
	{
	public:
		wProSelection()
		{
		}

		wProSelection(ProSelection suf):wOHandle<ProSelection>(suf)
		{
		}

		~wProSelection()
		{
			ProError error = ProSelectionFree ( &m_data);
		}

		void alloc( ProAsmcomppath* p_cmp_path , 
			ProModelitem* p_mdl_itm  )
		{
			ProError err = ProSelectionAlloc (p_cmp_path,p_mdl_itm,&m_data); 

		}

		void copyfrom( ProSelection sel ) 
		{
			ProError err =  ProSelectionCopy ( sel,&m_data);
		}

		ProModelitem GetModelitem()
		{
			ProModelitem mdl_item ;
			ProError err = ProSelectionModelitemGet (m_data, &mdl_item);
			return mdl_item;
		}

		static wProSelectionCollection_ptr Select(char  option[],int max_count)
		{
			ProError error = PRO_TK_NO_ERROR;

			ProSelection* sel = NULL;    
			int n = 0;
			error = ProSelect(option,max_count,NULL,NULL,NULL,NULL,&sel,&n);
			if(error != PRO_TK_NO_ERROR || n != 1)
			{
				PROE_THROW(error,Select);
			}
			if(n>0)
			{
				wProSelectionCollection_ptr Sc(new wProSelectionCollection());
				for(int i = 0 ; i< n ; i++)
				{

					wProSelection_ptr psel( new wProSelection());
					psel->alloc(NULL,NULL);
					psel->copyfrom(sel[i]);
					Sc->push_back(psel);
				}
				return Sc;
			}
			else
				return wProSelectionCollection_ptr();
	

		}




	};


}